let state = {
  id: "",
  name: "",
  host: "",
  port: "",
  user: "",
  password: "",
  database: "",
};
let getters = {
  id: (state) => state.id,
  name: (state) => state.name,
  host: (state) => state.host,
  port: (state) => state.port,
  database: (state) => state.database,
};
let mutations = {
  reset(state, linkInfo) {
    //初始化
    state.id = linkInfo.id;
    state.name = linkInfo.name;
    state.host = linkInfo.host;
    state.port = linkInfo.port;
    state.user = linkInfo.user;
    state.password = linkInfo.password;
    state.database = linkInfo.database;
    //state = linkInfo;
    //console.log(linkInfo);
  },
  setName(state, name) {
    // 设置名称
    state.name = name;
  },
  setHost(state, host) {
    // 设置域名
    state.host = host;
  },
  setPort(state, port) {
    // 设置端口
    state.port = port;
  },
  setDatabase(state, database) {
    // 设置数据库
    state.database = database;
  },
};
let actions = {
  testActions({ commit }, num) {
    setTimeout(() => {
      commit("setTotal", num);
      console.log(num);
    }, 2000);
  },
};
export default { state, getters, mutations, actions };
